package com.pig4cloud.pig.flow.config;

import com.pig4cloud.pig.flow.intecepter.LogInterceptor;
import org.camunda.bpm.engine.IdentityService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author mobai
 */
@Configuration
public class WebConfigurerAdapter implements WebMvcConfigurer {
	@Autowired
	private IdentityService identityService;

	@Bean
	public LogInterceptor logInterceptor() {
		return new LogInterceptor(identityService);
	}

	@Override
	public void addInterceptors(InterceptorRegistry registry) {
		registry.addInterceptor(logInterceptor()).addPathPatterns("/**");
	}
}
